INCLUDE_DIR = ./include
#export INCLUDE_DIR
#LIBS := libbackup.a liboneway.a libtwoway.a 

LIBS := ./lib/*.a
CC=gcc
CFLAGS = -I$(INCLUDE_DIR) -Wall -g

SUBDIRS := ./backup ./oneway_syn ./twoway_syn
SOURCES := $(wildcard *.c)
CHEADERS := $(wildcard *.h)

objects := $(patsubst %.c,%.o,$(wildcard *.c))  

RM = rm -rf
target = main
MAKE = make

all: $(target)

$(objects) : %.o: %.c
	$(CROSS_COMPILE)gcc -c $(CFLAGS) $< -o $@  

$(target): $(objects)
	for dir in $(SUBDIRS); do $(MAKE) -C $$dir all || exit 1; done
	$(CC) $(CFLAGS) $^ -o $@   $(LIBS) -lpthread

clean:
	@for dir in $(SUBDIRS); do make -C $$dir clean|| exit 1; done
	$(RM) $(objects)  $(LIBS) $(target)
.PHONY: all clean
